<?php

    $servername = "localhost";
    $username = "root";
    $password = "root123";


    $conn = new mysqli($servername, $username, $password);
    if ($conn->connect_error) {
        die("连接失败：".$conn->connect_error);
    }
        echo "数据库连接成功！",PHP_EOL;


    $dbname = "OOPDB";
    $conn->query("USE OOPDB");
    //   给特定的数据库建表
    $sql2 = "CREATE TABLE IF NOT EXISTS fish (
            id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            name VARCHAR(30) NOT NULL comment \"名字\",
            weight FLOAT NOT NULL comment '重量',
            kind VARCHAR(30) NOT NULL comment '种类',
            crea_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间'
    )comment '信息'";
    if ($conn->query($sql2) === true){
        echo "数据表创建成功！";
    } else {
        echo "数据表创建失败：".$conn->error;
    }

    $conn->close();


?>